﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

public partial class cn_pic : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetAdsInfo();
        }
    }

    private void GetAdsInfo()
    {
        string sql = "select top 5 * from Whir_U_News where TypeID=4 or TypeID in (select ColumnID from Whir_Column where ParentId=4) and UploadImg<>'' and  IsTop='是' order by CreateDate desc";
        DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
        rptAdsList.DataSource = dt;
        rptAdsList.DataBind();

        StringBuilder sb = new StringBuilder();
        for (int j = dt.Rows.Count - 1; j >= 0; j--)
        {
            string str = "";
            int n = j + 1;
            if (j == 0)
                str = " class=\"current\" ";
            sb.AppendLine(string.Format("<li {0} id=\"banners_{1}\">{1}</li>", str, n));
        }
        ltrNums.Text = sb.ToString();
    }
    protected void rptAdsList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Literal ltrNum = e.Item.FindControl("ltrNum") as Literal;
        Literal ltrStrClass = e.Item.FindControl("ltrStrClass") as Literal;

        int n = e.Item.ItemIndex + 1;
        if (ltrNum != null)
        {

            ltrNum.Text = n.ToString();
        }
        if (e.Item.ItemIndex == 0)
        {
            ltrStrClass.Text = "current";
        }
    }
}
